package com.sys.common.exception.file;

import java.io.Serial;
import java.util.Arrays;

/**
 * 文件上传 误异常类
 *
 * @author LGY
 */
public class InvalidExtensionException extends FileUploadException {

    @Serial
    private static final long serialVersionUID = -7365387481456218317L;

    private String[] allowedExtension;

    private String extension;

    private String filename;

    public InvalidExtensionException(String[] allowedExtension, String extension, String filename) {
        super("文件[" + filename + "]后缀[" + extension + "]不正确，请上传" + Arrays.toString(allowedExtension) + "格式");
        this.allowedExtension = allowedExtension;
        this.extension = extension;
        this.filename = filename;
    }

    public String[] getAllowedExtension() {
        return allowedExtension;
    }

    public String getExtension() {
        return extension;
    }

    public String getFilename() {
        return filename;
    }

    public static class InvalidImageExtensionException extends InvalidExtensionException {

        @Serial
        private static final long serialVersionUID = -5446035893079257202L;

        public InvalidImageExtensionException(String[] allowedExtension, String extension, String filename) {
            super(allowedExtension, extension, filename);
        }
    }

    public static class InvalidFlashExtensionException extends InvalidExtensionException {

        @Serial
        private static final long serialVersionUID = 1122977824145329547L;

        public InvalidFlashExtensionException(String[] allowedExtension, String extension, String filename) {
            super(allowedExtension, extension, filename);
        }
    }

    public static class InvalidMediaExtensionException extends InvalidExtensionException {

        @Serial
        private static final long serialVersionUID = 1544230528080896920L;

        public InvalidMediaExtensionException(String[] allowedExtension, String extension, String filename) {
            super(allowedExtension, extension, filename);
        }
    }

    public static class InvalidVideoExtensionException extends InvalidExtensionException {

        @Serial
        private static final long serialVersionUID = 5848331060435958436L;

        public InvalidVideoExtensionException(String[] allowedExtension, String extension, String filename) {
            super(allowedExtension, extension, filename);
        }
    }
}
